package io.lw.springbootamq.controller;


import io.lw.springbootamq.constant.Constant;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class SendController {
    @Autowired
    private AmqpTemplate amqpTemplate;

    @RequestMapping("/send")
    public String send() {
        String content = "Date:" + new Date();
        amqpTemplate.convertAndSend(Constant.QUEUE_NAME_1, Constant.QUEUE_NAME_1 + content);
        amqpTemplate.convertAndSend(Constant.QUEUE_NAME_2, Constant.QUEUE_NAME_2 + content);
        return content;
    }

}